﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm15 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonInsert_Click(object sender, EventArgs e)
        {
            var name = this.dc.CompanyDetails.Where(a => a.companyname.Equals(this.companyname.Value)).ToList();
            if (name.Count > 0)
            {
                this.Labelkq.Text = "Company name already exists";
            }
            else
            {
                string companyname = this.companyname.Value;
                string phone = this.phone.Value;
                string address = this.address.Value;
                string url = this.companyurl.Value;
                adcompany(companyname, phone, address, url);
            }

        }
        public void adcompany(string companyname, string phone, string address, string url)
        {
            CompanyDetail comp = new CompanyDetail();
            comp.companyname = companyname;
            comp.phone = phone;
            comp.address = address;
            comp.companyurl = url;
            this.dc.CompanyDetails.InsertOnSubmit(comp);
            this.dc.SubmitChanges();
            this.Labelkq.Text = "Insert Successful";
        }
    }
}